// 请求地址
const baseUrl = 'http://47.105.108.42:7300/mock/5d31801b3faf824360475428'

const http = (opt) => {
	opt = opt || {}
    opt.url = opt.url || ''
    opt.data = opt.data || {}
    opt.method = opt.method || 'POST'
    opt.header = opt.header || {
        "Content-Type": "application/json"
    }
    opt.success = opt.success || function () {}
	uni.request({
		url: baseUrl + opt.url,
        data: opt.data,
        method: opt.method,
        header: opt.header,
        dataType: 'json',
        success: function (res) {
            opt.success(res.data);
        },
        fail: function () {
            uni.showToast({
                title: '请稍后重试'
            });
        }
	})
}

export default http